package com.starbaba.stat.view;

import java.io.IOException;
import java.util.List;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.starbaba.stat.service.StatOneKeyApiService;
import com.starbaba.stat.service.impl.StatOneKeyApiServiceImpl;
import com.tuanzi.server.loan_base.model.db.stat.StatOneKeyApiOrder;

/**
 * 外推一键API订单统计Action
 * @author chenweijun
 *
 */
@SuppressWarnings({"rawtypes", "unchecked", "serial"})
public class StatExternalOneKeyApiOrder extends BaseAction implements ModelDriven<StatOneKeyApiOrder>{
	
	private StatOneKeyApiOrder model;
	private StatOneKeyApiService service;
	
	
	public StatExternalOneKeyApiOrder(){
		this.service = new StatOneKeyApiServiceImpl();
	}

	@Override
	public StatOneKeyApiOrder getModel() {
		if(model == null){
			model = new StatOneKeyApiOrder();
		}
		return model;
	}
	
	public void getList(){
		
		parsePageRequest();
		PageResponse pageResponse=new PageResponse();
		paramsMap=PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		
		List<StatOneKeyApiOrder> list = service.statExternalOneKeyApiOrder(paramsMap, pageRequest.getIDisplayStart(),pageRequest.getIDisplayLength());
		int count=service.countExternalOneKeyApiOrder(paramsMap);
		pageResponse.setITotalDisplayRecords(count);
		pageResponse.setITotalRecords(count);
		try {
			pageResponse.setAaData(list);
			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
		} catch(IOException e) {
			LogService.error(e);
		}
		
	}

}
